/************************************************************************************
* StarWidget.h                                                                      *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef STARWIDGET_H
#define STARWIDGET_H

#include <QWidget>
#include "common/CommonTypes.h"

class StarWidget : public QWidget {
    Q_OBJECT

    MediaRating m_rating;
    MediaRating m_floatingRating;
    MediaRating m_oldRating;
    QPixmap*    m_star;
    QPixmap*    m_sadStar;

public:
    static const int MAX_STARS = 5;
    explicit StarWidget(MediaRating rating, QWidget *parent = 0);
    ~StarWidget();
    QSize sizeHint() const;
    MediaRating rating();
    MediaRating floatingRating();

signals:
    void ratingSet(MediaRating rating);

protected:
    void paintEvent(QPaintEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
//    static void initStars();

public slots:
    void setRating(MediaRating rating);
    static void paint(MediaRating rating, QPainter* painter, int x, int y);
};

#endif // STARWIDGET_H
